const container = require('./container')

const start = async () => {
  try {
    const nacos = container.resolve('nacos')
    if (nacos) {
      process.on('exit', async () => {
        await nacos.down()
      })
      await nacos.up(async () => {
        const app = container.resolve('app')
        await app.start()
      })
    } else {
      const app = container.resolve('app')
      await app.start()
    }
  } catch (error) {
    console.log(error)
    process.exit(0)
  }
}

start()
